package ${configuration.javaModelPackage}.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import ${configuration.javaModelPackage}.service.${configuration.domainObjectName}Service;
import ${configuration.javaModelPackage}.entity.${configuration.domainObjectName};

/**
 *
 * <p>Title: ${configuration.domainObjectName}Controller</p>
 * <p>Description: </p>
 * 
 * @author ${configuration.author}
 * @date ${.now?string("yyyy-MM")}
 */
@RestController
@Api(value = "${configuration.domainObjectName}", tags = { "${configuration.domainObjectName}" })
@RequestMapping(value = "/${configuration.orgDomainObjectName}")
public class ${configuration.domainObjectName}Controller {

	@Autowired
	private ${configuration.domainObjectName}ServiceImpl service;
	
	@ApiOperation(value = "查询", produces = "application/json", response = ${configuration.domainObjectName}.class)
	@PostMapping(value = "/query${configuration.domainObjectName}")
	public AbstractApiResult gridQuery(@RequestBody ${configuration.domainObjectName} obj,@ModelAttribute PageParam pageParam) {
		PageResult resultData = this.service.gridQuery(obj,pageParam);
		return AbstractApiResult.success(resultData);
	}
	
	@ApiOperation(value = "保存", produces = "application/json", response = ${configuration.domainObjectName}.class)
	@PostMapping(value = "/save${configuration.domainObjectName}")
	public AbstractApiResult save(@RequestBody ${configuration.domainObjectName} pObj) {
		${configuration.domainObjectName} obj = this.service.save(pObj);
		return AbstractApiResult.success(obj);
	}
	
	@ApiOperation(value = "删除", produces = "application/json", response = String.class)
	@DeleteMapping(value = "/delete${configuration.domainObjectName}")
	public AbstractApiResult delete(@RequestBody List<String> ids) {
		this.service.delete(ids);
		return AbstractApiResult.success("success");
	}
	
}